﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.TD
{
	public class OdDbTypedId : OdDbObjectId
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbTypedId(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbTypedId_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbTypedId obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbTypedId()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbTypedId(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdDbTypedId(OdDbObjectId source, ReferenceType refType) : this(TD_DbPINVOKE.new_OdDbTypedId__SWIG_0(OdDbObjectId.getCPtr(source), (int)refType), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbTypedId(OdDbObjectId source) : this(TD_DbPINVOKE.new_OdDbTypedId__SWIG_1(OdDbObjectId.getCPtr(source)), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbTypedId() : this(TD_DbPINVOKE.new_OdDbTypedId__SWIG_2(), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public ReferenceType getRefType()
		{
			ReferenceType result = (ReferenceType)TD_DbPINVOKE.OdDbTypedId_getRefType(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setRefType(ReferenceType refType)
		{
			TD_DbPINVOKE.OdDbTypedId_setRefType(this.swigCPtr, (int)refType);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbTypedId Assign(OdDbObjectId rhs)
		{
			OdDbTypedId result = new OdDbTypedId(TD_DbPINVOKE.OdDbTypedId_Assign(this.swigCPtr, OdDbObjectId.getCPtr(rhs)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
